﻿/*
 * FileName: MatchPayEngine.cs
 * Module: Core
 * Author: Gourav Das
 * Created: 04/2011
 * Modifications:
 * Copyright: Gourav Das, 2011
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _22yards.IndependentModules;
namespace _22yards.Core
{
    public struct Shot
    {
        public short BattingShot;
        public short ShotRegion;
        public float AngleOfElevation;
        public short Power;

        public void Reset()
        {
            BattingShot = -1;
            ShotRegion = -1;
            AngleOfElevation = -1.0f;
            Power = -1;
        }
    }

    public class MatchPlayEngine
    {
        //private TournamentStructure.Match currentMatch;

        private DynamicMessageStore DMS = new DynamicMessageStore();

        public DynamicMessageStore MessageStore
        {
            get
            {
                return DMS;
            }
            set
            {
                DMS = value;
            }
        }

        public short InningsCompleted { get; set;}
        private short OversInCurrentInningsCompleted;
        private short OversInCurrentDayCompleted;

        private short TotalOversBowledbyTeam1;
        private short TotalExtrasBowledbyTeam1;
        private short TotalOversBowledbyTeam2;
        private short TotalExtrasBowledbyTeam2;

        public Match match;

        public MatchPlayEngine()
        {
            match = new Match();
        }

        public void InitMatch(Match _match)
        {
            match = _match;

            InningsCompleted = 0;
            OversInCurrentInningsCompleted = 0;
            OversInCurrentDayCompleted = 0;

            TotalOversBowledbyTeam1 = 0;
            TotalExtrasBowledbyTeam1 = 0;
            TotalOversBowledbyTeam2 = 0;
            TotalExtrasBowledbyTeam2 = 0;

        }

        public void TossCoin(int call /* 0 for head, 1 for call*/)
        {
            Toss.Call(ref match.Team1, ref match.Team2, call);
        }

        private short GenerateBall()
        {
            throw new NotImplementedException();
        }

        private Shot GenerateShot()
        {
            throw new NotImplementedException();
        }

        public bool PlayBall()
        {
            //Generate Ball
            //Generate Shot
            //record score
            //Fillup ball class and add to score class
            //Change Over, batsman ends, bowlers if necessary.
            //If all above are successful, return true
            throw new NotImplementedException();
        }

        public bool PlayOver()
        {
            throw new NotImplementedException();
        }

        public bool PlayCustomOvers()
        {
            throw new NotImplementedException();
        }
    }
}

